''' 用户字典：{'1001':'zhangsan', '1002':'lisi', '1005':'tom', '1008':'jerry'},分数列表[['1005', 98], ['1009', 102], ['1002', 85], ['1001', 98], ['1007', 120]]
    请使用匿名函数，根据第一个字典中用户信息返回对应的分数，如果没有对应分数输出0。最后输出信息，输出格式举例：“id为1001的用户zhangsan的分数是98”
'''
dit = {'1001':'zhangsan','1002':'lisi','1005':'tom','1008':'jerry'}
lst = [['1005', 98],['1009', 102],['1002', 85],['1001', 98],['1007', 120]]

def print_user_score(x:dict, y:list):
    dict_score = dict(y)
    user_score = map(lambda z:(z, x[z], dict_score.get(z, 0)), x.keys())
    for item in user_score:
        print('id为{}的用户{}的分数是{}'.format(*item))

print_user_score(dit, lst)

# 字典、自带函数map和匿名函数都用的非常灵活，非常棒！

# 输入一个英文句子，翻转句子中的单词顺序，但单词内字符的顺序不变（注意标点符号的位置）

phase = 'Whether you fail or fly, at least you tried.'

def reorder(x:str):
    lst = []
    while ',' in x:
        newtuple = x.partition(',')
        lst = [newtuple[0].strip()] + lst
        x = newtuple[-1]
    lst = [x.strip(' .')] + lst
    ordered = ', '.join(map(lambda z:' '.join(reversed(z.split(' '))), lst)) + '.'
    return ordered

print(reorder(phase))

# 注意标点符号的位置